package com.java.simple.study.jvm.memstruct.stack;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.util.Arrays;
import java.util.List;

/**
 * @author zhoujunlin
 * @date 2021/12/11
 * @desc 演示栈内存溢出
 * StackOverflowError
 **/
public class Demo1_4 {

    public static void main(String[] args) throws JsonProcessingException {
        Emp emp = new Emp();
        emp.setName("打工人");

        Dept dept = new Dept();
        dept.setName("天堂营业部");
        dept.setEmpList(Arrays.asList(emp));

        emp.setDept(dept);

        ObjectMapper objectMapper = new ObjectMapper();
        System.out.println(objectMapper.writeValueAsString(dept));

    }

}


@Data
class Emp {

    private String name;

    /*@JsonIgnore*/
    private Dept dept;
}

@Data
class Dept {

    private String name;

    private List<Emp> empList;
}
